package org.shana.shortlink.admin.remote;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.TypeReference;
import org.shana.shortlink.admin.common.convention.result.Result;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 短链接中台远程调用服务
 */
public interface LinkInfoRemoteService {


    /**
     * 移除短链接
     *
     * @param requestParam 短链接移除请求参数
     */
    default Result<String> getTitleByUrl(@RequestParam("url") String url) {
        System.out.println(url);
        String resultStr = HttpUtil.get("http://127.0.0.1:8081/api/v1/short-link/core/linkInfo/title?url=" + url);
        return JSON.parseObject(resultStr, new TypeReference<>() {
        });
    }

}
